﻿using ApiManage.Models.MongoMappings;
using MongoDB.Bson;
using MongoDB.Driver;
using Rhonin.Common;
using Rhonin.Common.Components;
using Rhonin.Common.Dapper;

namespace ApiManage.Core.Repository.MongoDB
{
    public interface ISysRepository<T> : IMongoRepository<T, ObjectId> where T : BaseMongoRecord { }
    public class SysRepository<T> : MongoRepository<T, ObjectId>, ISysRepository<T> where T : BaseMongoRecord
    {
        protected override IMongoCollection<T> Collection => ObjectContainer.Resolve<SysContentDatabase>().Database.GetCollection<T>(CollectionName);
    }
    [Component(LifeStyle.Singleton)]
    public class SysContentDatabase : MongoDatabase
    {
        public SysContentDatabase() : base(AppConfigurationServices.Configuration["MongoDb:SysContent"])
        {
        }
    }
}
